package com.project.controller;

import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService service;

    @RequestMapping("login")
    public String login(String name, String pwd) {
        UserBean userBean = service.login(name, pwd);
        if (userBean != null) {
            return "登陆成功";
        } else {
            return "登陆失败";
        }
    }

    @RequestMapping("add")
    public String add(UserBean userBean) {

        service.add(new UserBean(userBean.getName(), userBean.getPwd(), userBean.getGrade(), userBean.getBirthday()));
        return "添加成功";
    }
}
